#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;
int n,a,b,c,d;
int Min;
int Max;
int main(int argc,char **argv){
    cin >> n >> a >> b >> c >> d;
    Min = Max = 0;
    Min = min(Min,a-d);
    Max = max(Max,a-d);

    Min = min(Min,b-c);
    Max = max(Max,b-c);

    Min = min(Min,a+b-c-d);
    Max = max(Max,a+b-c-d);

    int len = Max-Min;

    long long ans = n;
//    cout << "len:" << len << endl;
    if(len<=n&&len>=0){
        ans *= (n-len);
    }else{
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}
